import axios from '@/plugins/axios';
const BASE_API = import.meta.env.VITE_APP_BASE_APIURL as string;

import { CommontTypes, ResponseVo, CouponTypes, PageResult } from '@/type';

export namespace CouponService {
  export const pageCoupon = async (data:CouponTypes.PageCouponType & CommontTypes.IPaginationParam): Promise<ResponseVo<PageResult<CouponTypes.ICouponItem>>> => {
    let res:ResponseVo<any> = await axios.get('/coupon/page',{params:data, baseURL: BASE_API});
    return res;
  };

  export const addCoupon = async (data:CouponTypes.ICouponItem): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/coupon/add',data,{baseURL: BASE_API});
    return res;
  };

  export const editCoupon = async (data:CouponTypes.ICouponItem): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/coupon/edit',data,{baseURL: BASE_API});
    return res;
  };

  export const detailCoupon = async (id:number): Promise<ResponseVo<CouponTypes.ICouponItem>> => {
    let res:ResponseVo<any> = await axios.get('/coupon/detail',{params:{id}, baseURL: BASE_API});
    return res;
  };
}
